package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.Between;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.travel.model.CheckInImplement.CheckStatus;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Indexed;

import javax.persistence.*;
import java.util.Date;

/**
 * 餐饮类型
 * */

@Entity
@Table(name = "travel_dinner")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class)})
public class Dinner extends BaseModel {

	private static final long serialVersionUID = 594923241460566519L;
	
	@Id
	@In
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	private Long pkDinner;
	
	/**餐饮类别 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkCheckInDinner")
	private CheckInDinner checkInDinner;
	
	/**餐饮类别 */
	@Enumerated(EnumType.STRING)
	@Field
	@FieldBridge(impl = EnumBridge.class)
	private DinnerSort dinnerSort;
	
	/**用餐时间 */
	@Column
	@Field
	private String dinnerDate;
	
	/** 用餐人数 */
	@Column
	@Field
	private Double perNumber;
	
	/** 标准*/
	@Column
	@Field
	private String  level;
	
	/** 用餐地点*/
	@Column
	@Field
	private String dinnerAddress;
	
	/**口味 */
	@Column
	@Field
	private String taste;
	
	/** 偏好 */
	@Column
	@Field
	private String preference;
	
	/** 指定菜*/
	@Column
	@Field
	private String species;
	
	/** 酒水 饮料*/
	@Column
	@Field
	private String drinks;
	
	/** 状态	待落实，已落实 */
    @Enumerated(EnumType.STRING)
    @Field
    @FieldBridge(impl = EnumBridge.class)
    private CheckStatus status;
    
    /** 早午晚当天日期*/
    @Column
    @Field
    @Between
    private Date dateOfDinner;
	
    /** 是否有效 */
	@Column
	private Boolean isValid;
    
	@Version
	private Integer version;

	
	@JsonSerialize(using = EnumSerializer.class)
	public enum DinnerSort {
		Breakfast("早餐"), Lunch("午餐"),Supper("晚餐");

		private String display;

		DinnerSort(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}
	
	public Long getPkDinner() {
		return pkDinner;
	}

	public void setPkDinner(Long pkDinner) {
		this.pkDinner = pkDinner;
	}
	
	public CheckInDinner getCheckInDinner() {
		return checkInDinner;
	}

	public void setCheckInDinner(CheckInDinner checkInDinner) {
		this.checkInDinner = checkInDinner;
	}

	public DinnerSort getDinnerSort() {
		return dinnerSort;
	}

	public void setDinnerSort(DinnerSort dinnerSort) {
		this.dinnerSort = dinnerSort;
	}

	public String getDinnerDate() {
		return dinnerDate;
	}

	public void setDinnerDate(String dinnerDate) {
		this.dinnerDate = dinnerDate;
	}

	public Double getPerNumber() {
		return perNumber;
	}

	public void setPerNumber(Double perNumber) {
		this.perNumber = perNumber;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getDinnerAddress() {
		return dinnerAddress;
	}

	public void setDinnerAddress(String dinnerAddress) {
		this.dinnerAddress = dinnerAddress;
	}

	public String getTaste() {
		return taste;
	}

	public void setTaste(String taste) {
		this.taste = taste;
	}

	public String getPreference() {
		return preference;
	}

	public void setPreference(String preference) {
		this.preference = preference;
	}

	public String getSpecies() {
		return species;
	}

	public void setSpecies(String species) {
		this.species = species;
	}

	public String getDrinks() {
		return drinks;
	}

	public void setDrinks(String drinks) {
		this.drinks = drinks;
	}

	public CheckStatus getStatus() {
		return status;
	}

	public void setStatus(CheckStatus status) {
		this.status = status;
	}

	public Date getDateOfDinner() {
		return dateOfDinner;
	}

	public void setDateOfDinner(Date dateOfDinner) {
		this.dateOfDinner = dateOfDinner;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Boolean getIsValid() {
		return isValid;
	}

	public void setIsValid(Boolean isValid) {
		this.isValid = isValid;
	}
	

}
